package com.hui.web.servlet.roomServlet;

import com.hui.bean.RoomBean;
import com.hui.service.IRoomService;
import com.hui.service.impl.RoomServiceImpl;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;

@WebServlet(name = "RoomShowServlet",urlPatterns = "/room/index")
public class RoomShowServlet extends HttpServlet {

    @Override
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

        IRoomService roomService=new RoomServiceImpl();
        List<RoomBean> allRooms = roomService.getAllRooms();
        System.out.println(allRooms);
        request.setAttribute("allRooms",allRooms);
        request.getRequestDispatcher("/page/room/index.jsp").forward(request, response);
    }

    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        doPost(request, response);
    }
}
